package com.google.code.whitetask;

import java.util.concurrent.ConcurrentHashMap;

@SuppressWarnings("serial")
public class Context extends ConcurrentHashMap<String, Object> {

  private static final String LAST_RESULT_KEY = "_lastResult";
  private static final String LAST_TASK_KEY = "_lastTask";

  public void setLastTask(Task task) {
    put(LAST_TASK_KEY, task);
  }

  public Task getLastTask() {
    return (Task)get(LAST_TASK_KEY);
  }

  public void setLastResult(Result result) {
    put(LAST_RESULT_KEY, result);
  }

  public Result getLastResult() {
    return (Result)get(LAST_RESULT_KEY);
  }
  
  public boolean isThereLastTaskBeingRan() {
    return getLastResult() != null && getLastTask() != null;
  }
}
